<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>recheck</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="assets/layer/layer/theme/default/layer.css"/>
    <link rel="stylesheet" href="angularjs/pagination.css">
    <script src="../homePage/js/jquery-1.9.1/jquery.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
    <script src="layer/layer.js"></script>
    <script src="angularjs/angular.min.js"></script>
    <script src="angularjs/pagination.js"></script>
</head>
<style type="text/css">
    .main-panel {
        background-color: #FFFFFF !important;
    }

    .content {
        background-color: #FFFFFF !important;
    }
</style>

<body ng-app="myApp" ng-controller="myCtrl" ng-init="select()">
<div class="wrapper">
    <div class="main-header">
        <div class="logo-header">
            <a href="Audit.html" class="logo">
                <img src="../pay/img/logo.png" style="height: 40px;width: 100px">审核部
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse"
                    aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <nav class="navbar navbar-header navbar-expand-lg float-right">
            <div class="container-fluid text-right">
                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">

                    <li class="nav-item dropdown">
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <tbody id="theuser">{{username}}</tbody>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <div class="user-box">

                                    <div class="u-text">
                                        <h4>用户名</h4>
                                        <p class="text-muted"></p>
                                        <a ng-click="quiet()" class="btn btn-rounded btn-danger btn-sm">退出登录</a>
                                    </div>
                                </div>
                            </li>

                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="scrollbar-inner sidebar-wrapper">
            <ul class="nav">
                <li class="nav-item ">
                    <a href="Audit.html">
                        <i class="la la-fonticons"></i>
                        <p>审核订单</p>
                        <span class="badge badge-count">初审</span>
                    </a>
                </li>
                <li class="nav-item active">
                    <a href="recheck.html">
                        <i class="la la-fonticons"></i>
                        <p>审核订单</p>
                        <span class="badge badge-count">复审</span>
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="main-panel" ng-app="myApp" ng-controller="myCtrl" ng-init="select()">
        <div class="content">
            <div class=" card col-md-11">
                <div class="panel panel-info">
                    <div class="card card-header">
                        <h2>审核订单（复审）</h2>
                    </div>
                    <div class="panel panel-body">
                        <div class="form-inline">
                            <button class="btn btn-success" ng-click="search()">查询</button>
                            <label>报案号：</label><input ng-model="reportno" class="form-control">
                            <label>报案时间：</label><input ng-model="reporttime" type="date" class="form-control">
                            <label>保单号：</label><input ng-model="policynum" class="form-control">
                        </div>
                        <br/>
                        <table class="table table-hover table-bordered table-condensed table-striped text-center">
                            <tr>
                                <td>序号</td>
                                <td>报案号</td>
                                <td>客户提供的保单号</td>
                                <td>报案时间</td>
                                <td>最后修改时间</td>
                                <td>理赔单状态</td>
                                <td>审核人员id</td>
                                <td>赔付金额</td>
                                <td>定损人员id</td>
                                <td>备注</td>
                                <td>操作</td>
                            </tr>
                            <tr ng-repeat="c in list">
                                <td ng-bind="$index+1"></td>
                                <td>{{c.reportid}}</td>
                                <td>{{c.policynum}}</td>
                                <td>{{c.reporttime | date:'yyyy-MM-dd'}}</td>
                                <td>{{c.lastmodifytime | date:'yyyy-MM-dd'}}</td>
                                <td>{{c.reportstate}}</td>
                                <td>{{c.firstid}}</td>
                                <td id="money">{{c.money}}</td>
                                <td>{{c.secondid}}</td>
                                <td>{{c.remark}}</td>
                                <td>
                                    <button class="btn btn-warning" ng-click="recheck (c.policynum)"
                                            data-target=" #myModal" data-toggle="modal">审核
                                    </button>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="12">
                                    <tm-pagination conf="paginationConf"></tm-pagination>
                                </td>
                            </tr>
                        </table>
                    </div>

                    <!-- 模态框（Modal） -->
                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                         aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                        &times;
                                    </button>
                                    <h4 class="modal-title" id="myModalLabel">新增地区</h4>
                                </div>

                                <form id="addform">

                                    <input type="hidden" ng-model="policynum">
                                    <div class="input-group">
                                        <span class="input-group-addon">赔付金额为：</span>
                                        <label id="compensate"></label>
                                    </div>
                                    <div class="input-group">
                                        <label class="input-group">是否通过复审审核，为该用户赔付</label>
                                    </div>
                                    <div class="form-inline">
                                        <label>备注：</label>
                                        <input id="remark" class="form-control">
                                    </div>
                                </form>

                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default testModal" data-dismiss="modal">关闭
                                    </button>
                                    <button type="button" class="btn btn-primary" data-dismiss="modal"
                                            ng-click="passVerification(policynum)">
                                        通过审核
                                    </button>
                                    <button type="button" class="btn btn-primary" data-dismiss="modal"
                                            ng-click="turndown(policynum)">
                                        驳回
                                    </button>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal -->
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var app = angular.module("myApp", ['pagination']);
    app.controller("myCtrl", function ($scope, $http) {
        var admin = sessionStorage.getItem("admin");
        $scope.userid = JSON.parse(admin).userid;
        $scope.username = JSON.parse(admin).username;
        // $scope.select = function () {
        //     $http.get("http://localhost:9001/report/getAllReportByStates").success(function (data) {
        //         $scope.list = data.data;//更新页面数据
        //
        //     });
        //
        // }

        $scope.paginationConf = {
            currentPage: 1,//当前页，默认第一页
            itemsPerPage: 5,//每页显示条数，默认为5
            totalItems: 1000,//一共多少条，随查询数据更新
            perPageOptions: [2, 5, 10, 50],
            onChange: function () {
                var reportno = $("#reportno").val();
                //开始调用分页请求
                $scope.reportnoSearch($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
            }
        };


        //分页请求
        $scope.select2 = function (pageIndex, pageSize) {
            //login = layer.load(1);
            $http.get("http://localhost:9001/report/getAllReportByStates?pageIndex=" + pageIndex + "&pageSize=" + pageSize).success(function (data) {
                $scope.list = data.rows;//更新页面数据
                $scope.paginationConf.totalItems = data.total;//更新总记录总条数
                // layer.close(login);
            });
        };
        //报案号查询
        $scope.reportstate = '待复审';
        $scope.reportnoSearch = function (pageIndex, pageSize) {
            var tReport = {
                reportid: $scope.reportno,
                reporttime: $scope.reporttime,
                policynum: $scope.policynum,
                reportstate: $scope.reportstate
            };

            $http.post("http://localhost:9001/report/getReportbyReportid?pageIndex=" + pageIndex + "&pageSize=" + pageSize, tReport)
                .success(function (data) {
                    $scope.list = data.rows;
                    $scope.paginationConf.totalItems = data.total;//更新总记录总条数
                })

        }
        $scope.search = function () {
            $scope.reportnoSearch($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
        }
        //查看保单详情
        $scope.recheck = function (policynum) {
            $scope.policynum = policynum;
            $.ajax({
                url: "http://localhost:9001/policy/getReportbyPolicynum",
                data: {policynum: policynum},
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    res.data;
                    // alert(res.data.money);
                    $("#compensate").html(res.data.money);
                }
            });
        };

        //修改状态为驳回
        $scope.turndown = function (policynum) {
            var remark = $("#remark").val();
            alert(remark);
            $.ajax({
                url: "http://localhost:9001/report/turndown",
                data: {
                    // JSON.parse(sessionStorage.getItem("user").userid),
                    firstid: 23,
                    policynum: policynum,
                    remark: remark
                },
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    layer.msg(res.msg);

                    $scope.select();
                }
            })
        }

        //修改状态为待放款
        $scope.passVerification = function (policynum) {
            $.ajax({
                url: "http://localhost:9001/report/passVerification",
                data: {
                    // JSON.parse(sessionStorage.getItem("user").userid),
                    firstid: 23,
                    policynum: policynum
                },
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    layer.msg(res.msg);

                    $scope.select();
                }
            })

        }
        //退出登陆
        $scope.quiet = function () {
            sessionStorage.clear();
            window.location.href = "../adminLogin/login.html";
        }
    });

</script>
</html>
